package Java.com.wang.House;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Test {
    public static void main(String[] args) {
        ExecutorService exe = Executors.newFixedThreadPool(3);
        System.out.println("消费者和生产者的大战开始了------->>>>>>>>>");
        WareHouse wa = new WareHouse();
        Producer p = new Producer(wa, 1);
        Customer c = new Customer(wa, 1);
        Thread P1 = new Thread(p);
        //P1.start();
        Thread C1 = new Thread(c);
        //C1.start();
        exe.execute(P1);
        exe.execute(C1);
        exe.shutdown();
        while (true) {
            if (exe.isTerminated()) {
                System.out.println("结束了");
                break;
            }
        }
        System.out.println("消费者和生产者的资源抢占结束----->>>>>>>>>");
    }
}
